FROM python:3.11-slim

WORKDIR /app

# 安装构建依赖
RUN apt update && \
    apt install -y --no-install-recommends \
    git \
    # ping / ip route / ssh
    iproute2 iputils-ping openssh-client tcpdump ethtool && \
    apt clean && \
    rm -rf /var/lib/apt/lists/*

# 首先复制依赖文件，利用Docker缓存
COPY os-ken/requirements.txt os-ken/setup.py os-ken/setup.cfg os-ken/MANIFEST.in os-ken/README.rst ./os-ken/
COPY os-ken/os_ken/__init__.py ./os-ken/os_ken/

# 安装Python依赖，这一层会被缓存
RUN cd /app/os-ken && \
    PBR_VERSION=0.0.0 pip install -r requirements.txt && \
    pip install pbr

# 复制完整源码
COPY os-ken/ ./os-ken/

# 以开发模式安装，这样修改源码不需要重新安装
RUN cd /app/os-ken && \
    PBR_VERSION=0.0.0 pip install -e .

CMD ["bash"]
